package com.game.ThauanLopes;

import java.util.HashSet;

import com.game.ThauanLopes.*;

import android.content.res.AssetManager;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;

public class Player extends GameObject {
	
	public Side side;
	
	public int xVelocity = 4;
	public int yVelocity = 4;
	
	Bitmap bitmap;
	Sprite sprite;
	
	public int width = 50;
	public int height = 50;
	
	public int x = 0;
	public int y;

	public Paint paint;
	public int gameCanvasWidth;
	public int gameCanvasHeight;
	
	public Player(int canvasWidth, int canvasHeight, HashSet<GameObject> hs)
	{
		this.paint = new Paint();
		this.paint.setColor(Color.BLUE);
		
		side = side.RIGHT;
		
		this.gameCanvasWidth = canvasWidth;
		this.gameCanvasHeight = canvasHeight;
		
		this.y = Game.floor;
		
		this.bitmap = BitmapFactory.decodeResource(Game.resources, R.drawable.teste_android);
		sprite = new Sprite(this.bitmap, 3, 3);
		
		hs.add(this);
		
	}
		public void Update()
		{
			x += xVelocity;
			if(x + this.width > gameCanvasWidth)
			{	
				x = gameCanvasWidth - this.width;
			}
			if(x < 0)
			{
				x = 0;
			}
			
			this.sprite.Update(Game.deltaTime);
			
		}

	public void Stop()
	{
	}
	public void Resume()
	{
	}

	public void SetPotsition(float x, float y)
	{
		this.x = (int) x;
		this.y = (int) y;
	}
	
	public void Turn()
	{
		this.xVelocity = -xVelocity;
		switch(side)
		{
		case LEFT:
			side = side.RIGHT;
			break;
		case RIGHT:
			side = side.LEFT;
			break;
		}

	}

	@Override
	public void Draw(Canvas canvas)
	{
		Rect r = new Rect (x, y, this.width, this.height);
		sprite.Draw(canvas,r);
	}
	@Override
	public boolean collision(Rect fingersPos) {
		// TODO Auto-generated method stub
		return false;
	}

}
